package com.dingding.manager.modules.system.sql;

/**
 * 
 * @ClassName: UserSQL
 * @Description: 用户管理sql
 * @author SUNZHICHENG
 * @date 2016年12月2日 下午10:57:37
 * @version V2.6.2
 */
public class UserSQL {
	/**
	 * 根据用户名获取用户信息 SUNZHICHENG
	 */
	public static final String QUERY_USER_BY_NAME = " SELECT * FROM dd_sys_user a WHERE a.loginName = ? AND a.delFlag = 0 ";

	/**
	 * 查询用户和角色信息到权限表（存入session用）
	 */
	public static final String QUERY_USERINFO_BY_NAME = " select companyId,deptId,loginName,trueName,roleName,roleEnName,dataScope from dd_sys_user a, dd_sys_user_role b , dd_sys_role c where a.sysUserId =b.sysUserId and b.sysRoleId = c.sysRoleId and a.loginName = ? and a.userStatus = 1 ";
	
	/**
	 * 根据id获取用户信息
	 */
	
	public static final String QUERY_USER_BYID="  SELECT	a.sysUserId  sysUserId,	a.loginName  loginName,	a.`password` 'password',  a.trueName trueName,	a.phone phone, a.loginIp loginIp,	DATE_FORMAT(a.loginTime,'%Y-%m-%d %H:%I:%S') loginTime, a.userStatus userStatus,	a.createUserId createUserId,	DATE_FORMAT(a.createTime,'%Y-%m-%d %H:%I:%S') createTime,	a.updateUserId updateUserId,	DATE_FORMAT(a.updateTime,'%Y-%m-%d %H:%I:%S') updateTime, a.remarks ,d.cityName cityName, d.`organizationId` organizationId,  d.organizationName organizationName,  d.`organizationType` organizationType, c.`sysRoleId`  sysRoleId, c.roleName roleName,	c.roleEnName roleEnName FROM	dd_sys_user a,	dd_sys_user_role b,	dd_sys_role c,	dd_organization d WHERE	a.sysUserId = b.sysUserId AND b.sysRoleId = c.sysRoleId AND a.companyId = d.organizationId AND a.delFlag = 0 AND a.sysUserId = ? ";
	
	/**
	 * 根据用户id获取用户角色管理表
	 */
	public static final String QUERY_USER_ROLE=" SELECT * FROM dd_sys_user_role r where r.sysUserId = ? ";

	/**
	 * 根据用户名获取用户（判断用户是否存在）
	 */
	public static final String USER_BY_NAME=" SELECT * FROM dd_sys_user a WHERE a.loginName = ?  ";
}
